﻿<Code1:LoggedInPage 
    x:Class="GTasksPlus.Views.TaskView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:Code1="clr-namespace:GTasksPlus.Code" xmlns:Helpers1="clr-namespace:GTasksPlus.Helpers"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneAccentBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="696" d:DesignWidth="480"
    shell:SystemTray.IsVisible="True"
    d:DataContext="{d:DesignData SampleData/ItemViewModelSampleData.xaml}">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>
    
    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="140"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0">
            <StackPanel.Resources>
                <Helpers1:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            </StackPanel.Resources>
            <CheckBox Visibility="Collapsed" IsEnabledChanged="CheckBox_IsEnabledChanged"  IsEnabled="{Binding IsDataLoaded}">
            </CheckBox>
            <toolkit:PerformanceProgressBar x:Name="performanceProgressBar" 
                                            Visibility="{Binding IsDataLoaded, Converter={StaticResource BoolToVisibilityConverter}, Mode=OneWay}" IsIndeterminate="True" Height="5"/>
            <TextBlock x:Name="ApplicationTitle" Style="{StaticResource PhoneTextNormalStyle}" Margin="8,0">
            	<TextBlock.Foreground>
            		<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
            	</TextBlock.Foreground>
            </TextBlock>
            <TextBlock DataContext="{Binding ParentList}" x:Name="PageTitle" Text="{Binding title}" Margin="8,-7,8,0" Style="{StaticResource PhoneTextTitle1Style}">
            	<TextBlock.Foreground>
            		<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
            	</TextBlock.Foreground>
            </TextBlock>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1">
            <ListBox Name="TasksView" ItemsSource="{Binding Path=TaskItem}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
                            <StackPanel.Resources>
                                <Helpers1:TextLineBreakConverter x:Key="TextLineBreakConverter" />
                                <Helpers1:TaskStatusConverter x:Key="TaskStatusConverter" />
                            </StackPanel.Resources>
                            <CheckBox Tag="{Binding Path =id}" Click="CheckBox_Tap" IsChecked="{Binding status, Converter={StaticResource TaskStatusConverter}, Mode=TwoWay}" Foreground="{StaticResource PhoneInverseBackgroundBrush}" Background="{StaticResource PhoneSubtleBrush}" HorizontalAlignment="Center" VerticalAlignment="Center" >
                            </CheckBox>
                            <TextBlock Tap="Textblock_Tap" Height="Auto" Tag="{Binding id}" Width="420" TextWrapping="Wrap" Foreground="{StaticResource PhoneAccentBrush}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="24">
                                <Run Text="{Binding title}"/>
                                <Run Text="{Binding notes, Converter={StaticResource TextLineBreakConverter}, Mode= OneWay}" Foreground="{StaticResource PhoneSubtleBrush}" FontStyle="Italic" />
                            </TextBlock>
                        </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton Text="Add" Click="Add_Click" IconUri="/Images/new.png"/>
            <shell:ApplicationBarIconButton Text="Refresh" Click="Refresh_Click" IconUri="/Images/refresh.png"/>
            <shell:ApplicationBarIconButton Text="Email" Click="EmailTasks_Click" IconUri="/Images/email.png"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Click="Completed_Click" Text="Clear completed tasks" />
                <shell:ApplicationBarMenuItem Click="Logout_Click" Text="Logout" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</Code1:LoggedInPage>